/*
* Accord Software, Inc.
*
* Tutorial 09
*
* Send array of ints and array of 1 thru 4
* levels of pointers to ints
*/
#include "array.h"
static int nums[COUNT] = {
1, 2, 3, 4
};
static int *nump[COUNT] = {
&nums[0], &nums[1], &nums[2], &nums[3]
};
static int **num2p[COUNT] = {
&nump[0], &nump[1], &nump[2], &nump[3]
};
static int ***num3p[COUNT] = {
&num2p[0], &num2p[1], &num2p[2], &num2p[3]
};
static int ****num4p[COUNT] = {
&num3p[0], &num3p[1], &num3p[2], &num3p[3]
};
main(argc, argv)
int argc;
char *argv[];
{
int sum = 0;
int j;
char *prog = argv[0];
printf("%s sum = %d\n", prog, arraysum(nums));
tenplus(nums);
printf("%s sum = %d\n", prog, arraysump(nump));
tenplus(nums);
printf("%s sum = %d\n", prog, arraysum2p(num2p));
tenplus(nums);
printf("%s sum = %d\n", prog, arraysum3p(num3p));
tenplus(nums);
printf("%s sum = %d\n", prog ,arraysum4p(num4p));
exit(0);
}
/*
* increment array elements by 10
*/
tenplus(nums)
int *nums;
{
int j;
for (j = 0; j < COUNT; j++) {
*nums = *nums + 10;
nums++;
}
}